import { BasicColumn, FormSchema } from '@/components/Table';
import { isEmpty } from 'lodash-es';

export const useQianguaColumns = (): BasicColumn[] => {
  return [
    {
      title: '编号',
      dataIndex: 'id',
      width: 80,
    },
    {
      title: '平台名称',
      dataIndex: 'type',
      align: 'left',
      width: 120,
      customRender: ({ value }) => {
        if (value == 1) {
          return '千瓜平台';
        } else if (value == 2) {
          return '小红书话题';
        }
      },
    },
    {
      title: '任务名称',
      dataIndex: 'title',
    },
    {
      title: '任务状态',
      dataIndex: 'statusMsg',
      width: 150,
      customRender: ({ value }) => {
        return isEmpty(value) ? '未开始' : value;
      },
    },
    {
      title: '创建时间',
      dataIndex: 'created_at',
      width: 180,
    },
    {
      title: '更新时间',
      dataIndex: 'updated_at',
      width: 180,
    },
    {
      title: '创建者',
      dataIndex: 'creator',
      width: 150,
    },
  ];
};

export const useQianguaFormSchema = (): FormSchema[] => {
  return [
    {
      field: 'title',
      label: '任务名称',
      required: true,
      component: 'Input',
    },
    {
      field: 'type',
      label: '任务类型',
      component: 'Input',
      show: false,
    },
    {
      field: 'sheetType',
      label: '选择Sheet',
      component: 'Select',
      show: false,
    },
    {
      field: 'start_row',
      label: '第一个数据行',
      labelWidth: 110,
      required: true,
      component: 'InputNumber',
      componentProps: {
        min: 1,
      },
    },
    {
      field: 'end_row',
      label: '最后一个数据行',
      labelWidth: 120,
      component: 'InputNumber',
      componentProps: {
        min: 1,
      },
    },
    {
      field: 'condition.title',
      label: '话题',
      labelWidth: 120,
      required: true,
      component: 'Input',
    },
    {
      field: 'condition.pagesize',
      label: '抓取每页记录数',
      required: true,
      helpMessage: '一般情况下不需要修改',
      labelWidth: 140,
      component: 'Input',
      defaultValue: 20,
    },
    {
      field: 'condition.start_date',
      label: '发布时间',
      labelWidth: 120,
      component: 'Input',
      show: false,
    },
    {
      field: 'condition.end_date',
      label: '发布时间',
      labelWidth: 120,
      component: 'Input',
      show: false,
    },
    {
      field: 'datetime',
      label: '发布时间',
      component: 'RangePicker',
      componentProps: {
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
  ];
};

export const useDplistColumns = (): BasicColumn[] => {
  return [
    {
      title: '编号',
      dataIndex: 'id',
      width: 80,
    },
    {
      title: '昵称',
      dataIndex: 'name',
      align: 'left',
      width: 300,
      edit: true,
    },
    {
      title: '小红书ID',
      dataIndex: 'redId',
      align: 'left',
      width: 200,
      edit: true,
    },
    {
      title: '小红书链接',
      dataIndex: 'linkUrl',
      align: 'left',
      edit: true,
    },
    {
      title: '状态信息',
      dataIndex: 'msg',
      align: 'left',
      width: 200,
    },
  ];
};
